#include <stdio.h>
#include <stdlib.h>

#define MAX_N 1000
#define MAX_M 1000

const int dx[] = { -1, 1, 0, 0 };
const int dy[] = { 0, 0, -1, 1 };

typedef struct 
{
    int x, y;
} Point;

Point queue[MAX_N * MAX_M];
int front, rear;

void initQueue() 
{
    front = rear = 0;
}

void enqueue(int x, int y)
{
    queue[rear].x = x;
    queue[rear].y = y;
    rear++;
}

Point dequeue()
{
    return queue[front++];
}

int isEmpty() 
{
    return front == rear;
}

int main()
{
    int n, m;
    char grid[MAX_N][MAX_M + 1];
    int visited[MAX_N][MAX_M] = { 0 };
    int pref[MAX_N + 1][MAX_M + 1] = { 0 };

    scanf_s("%d %d", &n, &m);
    for (int i = 0; i < n; i++)
    {
        scanf_s("%s", grid[i]);
    }

    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            int val = (grid[i - 1][j - 1] == '*') ? 1 : 0;
            pref[i][j] = pref[i - 1][j] + pref[i][j - 1] - pref[i - 1][j - 1] + val;
        }
    }

    int ans = 0;
    for (int i = 0; i < n; i++) 
    {
        for (int j = 0; j < m; j++) 
        {
            if (grid[i][j] == '.' && !visited[i][j])
            {
                initQueue();
                enqueue(i, j);
                visited[i][j] = 1;
                int min_i = i, max_i = i;
                int min_j = j, max_j = j;

                while (!isEmpty()) 
                {
                    Point p = dequeue();
                    int x = p.x, y = p.y;
                    if (x < min_i) min_i = x;
                    if (x > max_i) max_i = x;
                    if (y < min_j) min_j = y;
                    if (y > max_j) max_j = y;

                    for (int d = 0; d < 4; d++) 
                    {
                        int nx = x + dx[d];
                        int ny = y + dy[d];
                        if (nx >= 0 && nx < n && ny >= 0 && ny < m)
                        {
                            if (grid[nx][ny] == '.' && !visited[nx][ny]) 
                            {
                                visited[nx][ny] = 1;
                                enqueue(nx, ny);
                            }
                        }
                    }
                }

                int total_star = pref[max_i + 1][max_j + 1] - pref[min_i][max_j + 1] - pref[max_i + 1][min_j] + pref[min_i][min_j];
                if (total_star == 0)
                {
                    ans++;
                }
            }
        }
    }

    printf("%d\n", ans);
    return 0;
}